package de.fhwf.mixedreality.client2007;

import de.fhwf.mixedreality.client.AbstractPositionsStorage;
import de.fhwf.mixedreality.client.IClient;
import de.fhwf.mixedreality.client.Vector;

public class PositionsStorage extends AbstractPositionsStorage {
	public PositionsStorage(Client2007 client) {
		super(client);
	}

	@Override
	public String getWorldString(boolean isLost) {
	  int myid = 0; //client.myID();
	  
		Vector v, v2;
		String ret = "myid " + myid + "\n" + "time 0\n" + "game on\n";
		if (isLost) {
			ret = ret + "lost\n";
		}
		for (int i = 0; i < IClient.MAX_PLAYERS; i++) {
			v = this.opponent(i);
			if (v.getAngle() != 0 || v.getLength() != 0) {
				ret += "op " + i + " " + v.getLength() + " " + v.getAngle() + "\n";
			}
		}
		for (int i = 0; i < IClient.MAX_PLAYERS; i++) {
			v = this.teammate(i);
			if (v.getAngle() != 0 || v.getLength() != 0) {
				ret += "tm " + i + " " + v.getLength() + " " + v.getAngle() + "\n";
			}
		}
		v = this.ball();
		ret += "ball " + v.getLength() + " " + v.getAngle() + "\n";
		v = this.myGoalPole1();
		v2 = this.myGoalPole2();
		ret += "mygoal " + v.getLength() + " " + v.getAngle() + " "
				+ v2.getLength() + " " + v2.getAngle() + "\n";
		v = this.opGoalPole1();
		v2 = this.opGoalPole2();
		ret += "opgoal " + v.getLength() + " " + v.getAngle() + " "
				+ v2.getLength() + " " + v2.getAngle() + "\n";
		v = this.myCornerFlag1();
		v2 = this.myCornerFlag2();
		ret += "mycorners " + v.getLength() + " " + v.getAngle() + " "
				+ v2.getLength() + " " + v2.getAngle() + "\n";
		v = this.opCornerFlag1();
		v2 = this.opCornerFlag2();
		ret += "opcorners " + v.getLength() + " " + v.getAngle() + " "
				+ v2.getLength() + " " + v2.getAngle() + "\n";
		return ret;
	}
}